<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <el-form :model="form" ref="form" :rules="rules" label-position="left" label-width="80px" size="medium">
          <el-form-item label="用户名" prop="username">
            <el-input v-model="form.username" placeholder="请输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="奖品昵称" prop="reward">
            <el-input v-model="form.reward" type="text" placeholder="请输入奖品昵称" class="width250"></el-input>
          </el-form-item>
          <el-form-item label="中奖时间" prop="getTime">
            <el-date-picker
              v-model="form.getTime"
              type="datetime"
              placeholder="选择日期时间"
              size="'mini'"
              value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="备注" prop="remarks">
            <el-input type="textarea" v-model="form.remarks" placeholder="请输入备注"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <span slot="footer" class="dialog-footer">
       <el-button size="medium" @click="cancel" class="width100 assign-prize-cancle">取 消</el-button>
       <el-button size="medium" type="primary" @click="save" class="width100">确 定</el-button>
    </span>
  </div>
</template>

<script>
import { form } from '@/build';
import { addWinningNoticeList } from '@/services/api/activity';

export default {
  name: 'addAwardDialog',
  mixins: [form],
  data() {
    return {
      form: {
        username: undefined,
        reward: undefined,
        getTime: undefined,
        remarks: undefined,
      },
      rules: {
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { max: 45, message: '长度不能超过45个字符' },
        ],
        reward: [
          { required: true, message: '请输入奖品昵称', trigger: 'blur' },
          { max: 30, message: '长度不能超过30个字符' },
        ],
        getTime: [
          { required: true, message: '请输入中奖时间', trigger: 'blur' },
        ],
        remarks: [
          { required: true, message: '请输入备注', trigger: 'blur' },
          { max: 255, message: '长度不能超过255个字符' },
        ],

      },
    };
  },
  mounted() {
    this.bindSave(addWinningNoticeList, 'saveForm', 'form', {
      afterSuccess: () => {
        this.$emit('refresh');
        this.cancel();
      },
    });
  },
  methods: {
    save() {
      // if (!this.limitFlag) {
      //   return;
      // }
      // this.limitFlag = false;
      this.doSave({ action: 'saveForm', form: 'form' });
    },
    cancel() {
      this.$emit('input', false);
    },
  },
};
</script>

<style lang="scss" scoped>
  .app-container{
    /deep/ .el-input{
      width: 100% !important;
    }
    text-align: center;
    padding: 0 30px 20px 30px;
    .scroll-time{
      width: 172px;
      margin-right: 10px;
    }
  }
</style>
